﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SuperSocket.WebSocket;
namespace SocketData
{
    class Program
    {
        static void Main(string[] args)
        {
            MyWS  ws = new MyWS();
            ws.NewSessionConnected +=(WebSocketSession session) =>
            {
                //Console.WriteLine(session.SessionID + "登录！");
            };
            ws.SessionClosed += (WebSocketSession session, SuperSocket.SocketBase.CloseReason value) =>
            {
                //Console.WriteLine(session.SessionID + "退出！");
            };

            if (!ws.Setup(20000))
            {
                Console.WriteLine("未能Set up ws");
            }
            if (!ws.Start()) //Setup with listening port
            {
                Console.WriteLine("未能启动ws");
            }
            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine("按q，退出！......");
                continue;
            }

            if (ws.State == SuperSocket.SocketBase.ServerState.Running)
                ws.Stop();
        }
    }
}
